//
//  NAError.m
//  NewApp
//
//  Created by 健 吕 on 12-6-9.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "NAError.h"

static NSString *NAErrorDiscrption[] = {
    @"无法解析数据",
    @"网络连接失败,请检查网络后重试!",
    @"数据格式错误",
    @"無法完成註冊，請稍後重試",
    @"無法完成請求，請稍後重試"
};


@implementation NAError

@synthesize code;

- (NSString *) errorDescprtion {
    
    return NAErrorDiscrption[self.code];    
}

+ (NAError *) errorWithCode:(NAErrorCode) code {
    NAError * error = [[NAError alloc] init];
    error.code = code;
    
    return [error autorelease];
}

- (void) showErrorMessage:(NSString *) title {
    NSString *message = [self errorDescprtion];
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 
                                                    message:message 
                                                   delegate:nil 
                                          cancelButtonTitle:@"確定" 
                                          otherButtonTitles:nil];
    
    [alert show];
    [alert release];
}

+ (void) showAlertMessageWithTitle:(NSString *) title message:(NSString *) message {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title 
                                                    message:message 
                                                   delegate:nil 
                                          cancelButtonTitle:@"確定" 
                                          otherButtonTitles:nil];
    
    [alert show];
    [alert release];
}


@end
